package com.example.seckill.utils;


import org.apache.commons.codec.digest.DigestUtils;

/**
 * MD5加密工具类
 */
public class MD5Utils {
    public static String md5(String src){
        return DigestUtils.md5Hex(src);
    }

    private static final String salt="1a2b3c4d";

    public static String inputPassToFormPass(String inPass){
        String str = salt.charAt(0) + salt.charAt(2) + inPass + salt.charAt(5) + salt.charAt(4);
        return str;
    }

    public static String formPassToDBPass(String formPass, String salt){
        String str = salt.charAt(0) + salt.charAt(2) + formPass +salt.charAt(2) + salt.charAt(4);
        return md5(str);
    }

    //  提供给外部调用
    public static String inputPassToDBPass(String inputPass, String salt){
        String formPass = inputPassToFormPass(inputPass);
        return formPassToDBPass(formPass, salt);
    }

    public static void main(String[] args) {
        System.out.println(inputPassToDBPass("123456",salt));
    }
}
